import React from "react";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";

import * as actions from "../actions";

import Add from "../components/add";
import List from "../components/list";


class App extends React.Component{
    constructor(props){
        super(props)
        console.log(props)
    }
    render(){
        return(
            <div>
                <h3>Write What You Want</h3>
                <List todo={this.props.todo} del={this.props.del} />
                <Add add={this.props.add}/>
            </div>
        )
    }
}

function mapStateToProps(state){
    return{
        todo : state.todo
    }
}
function mapDispatchRoProps(dispatch){
    return {
        add : bindActionCreators(actions.addTodo,dispatch),
        del : bindActionCreators(actions.delTodo,dispatch)
    }
}

App = connect(mapStateToProps,mapDispatchRoProps)(App)
export default App; 
